package Practice;

import java.util.Scanner;

public class Filter {
    public static boolean isPrime(int x){
        if (x < 2) return false;
        if (x == 2) return true;
        int x1 = (int) Math.sqrt(x);
        for (int i = 2; i <= x1; i++) {
            if (x%i==0)
                return false;
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        int[] num1 = new int[n];
        int k = 0;
        for (int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
            if (isPrime(num[i])){
                num1[k] = num[i];
                k++;
            }
        }
        for (int j = 0; j < k; j++) {
            System.out.print(num1[j]+" ");
        }
    }
}
